package com.six.controller;

import com.six.pojo.BuyPlan;
import com.six.result.Result;
import com.six.result.ResultUtils;
import com.six.service.BuyPlanService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "采购计划接口文档")
@RestController
@RequestMapping("/buyPlan")
@Slf4j
@CrossOrigin
public class BuyPlanController {

    @Autowired
    private BuyPlanService planService;

    @PostMapping("/list")
    public Result findList(){
        return null;
    }

    @PostMapping("/add")
    public Result add(@RequestBody BuyPlan buyPlan){
        buyPlan.setId(null);
        planService.add(buyPlan);
        return ResultUtils.buildSuccess();
    }

    @PutMapping("/update")
    public Result update(@RequestBody BuyPlan buyPlan){
        planService.updateById(buyPlan);
        return ResultUtils.buildSuccess();
    }

    @DeleteMapping("/delete/{id}")
    public Result delete(@PathVariable Long id){
        planService.removeById(id);
        return ResultUtils.buildSuccess();
    }
}
